package com.tenbent.product.base.servlet;

import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 自定义servlet
 *
 * @author Randy
 * 
 *         Created by ThinkPad on 2017/7/24.
 */
public class MyServlet extends HttpServlet {

    public static final String MAPPING = "/myServlet/*";

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name = StringUtils.isNoneEmpty(req.getParameter("name")) ? req.getParameter("name") : "Randy Yan";
		// TODO 自己的业务逻辑
		resp.getWriter().println("name is : " + name + " welcome in my servlet");
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}
}
